package cglib;

import org.junit.Test;

import java.lang.reflect.Proxy;

public class Client
{
    public static void main(String[] args)
    {
        DongTaiImplements d = new DongTaiImplements();
        DongTaiTest dongTaiTest = new DongTaiTest(d);
        Class<?> cls = d.getClass();

        DongTai dongTai = (DongTai) Proxy.newProxyInstance(cls.getClassLoader(), cls.getInterfaces(), dongTaiTest);
        dongTai.testD();
    }

    @Test
    public void test()
    {
        DongTaiImplements d = new DongTaiImplements();
        DongTaiTest dongTaiTest = new DongTaiTest(d);
        DongTai dongTai = (DongTai) dongTaiTest.getInterface();
        dongTai.testD();

        Dong dong = new Dong();
        dongTaiTest = new DongTaiTest(dong);
        DongInterface anInterface = (DongInterface) dongTaiTest.getInterface();
        anInterface.testDong();
    }
}
